import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Test_MyDoublyLinkedLIst {
    public static void main(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.add(5);
        list.add(4);
        list.add(3);
        list.add(2);
        list.add(1);

        for (int i = 0; i<list.size(); i++){
            System.out.print(list.get(i)+" ");
        }
        System.out.println();

        System.out.println("------------------");

        for(Integer x : list){
            System.out.print(x+" ");
        }
        System.out.println();

        System.out.println("------------------");

        ListIterator<Integer> list1 = list.listIterator();
        while (list1.hasNext()){
            System.out.print(list1.next()+" ");
        }
        System.out.println();

        System.out.println("------------------");

        ListIterator<Integer> list2 = list.listIterator(list.size());
        while (list2.hasPrevious()){
            System.out.print(list2.previous()+" ");
        }


    }


    public static void main1(String[] args) {
        MyDoublyLinkedList myDoublyLinkedList = new MyDoublyLinkedList();
        myDoublyLinkedList.addFirst(1);
        myDoublyLinkedList.addFirst(2);
        myDoublyLinkedList.addFirst(3);
        myDoublyLinkedList.addFirst(4);
        myDoublyLinkedList.addFirst(5);
        myDoublyLinkedList.addFirst(5);

        myDoublyLinkedList.display();

        System.out.println("============================");

        myDoublyLinkedList.addLast(0);
        myDoublyLinkedList.display();

        System.out.println("============================");

        myDoublyLinkedList.addIndex(0,6);
        myDoublyLinkedList.display();

        System.out.println("============================");

        boolean flg = myDoublyLinkedList.contains(2);
        System.out.println(flg);

        System.out.println("============================");

        myDoublyLinkedList.remove(0);
        myDoublyLinkedList.display();

        System.out.println("============================");

        myDoublyLinkedList.removeAllKey(5);
        myDoublyLinkedList.display();

        System.out.println("============================");

        int size = myDoublyLinkedList.size();
        System.out.println(size);

        System.out.println("============================");

        myDoublyLinkedList.clear();
        myDoublyLinkedList.display();


    }
}
